package sluentities;

import java.util.*;

import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Embedded;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;


/**
 * Created by chenhong on 2017/2/27.
 */

@Entity(value = "elements", noClassnameStored = true)
public class GrammarElementEntity {
    @Id
    protected ObjectId id;
    protected String name;
    protected Set<String> attnames=new HashSet<String>();
    @Embedded
    protected List<EmbedElementEntity> elelists= new ArrayList<EmbedElementEntity>();

    public GrammarElementEntity() {
        super();
    }

    public void setId(ObjectId id) {
        this.id = id;
    }

    public ObjectId getId() {
        return id;
    }

    public String getAttnamelist(){
        String s="";
        Iterator<String> it=attnames.iterator();
        while (it.hasNext())s=s+it.next()+",";
        if(attnames.size()>0)s=s.substring(0,s.length()-1);
        return s;
    }

    public Set<String> getAttnames(){return attnames;}

    public void setAttnames(Set<String> s){attnames=s;}

    public List<EmbedElementEntity> getElelists(){return this.elelists;}

    public void setElelists(List<EmbedElementEntity> list){elelists=list;}

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
